home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
String
/
src
/
io.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
715b
|
41 lines
#include <ctype.h>
#include "String.h"
#include <iomanip.h>
ostream &operator<<(ostream &os,const RJS_String &s) {
os.write(s.cptr(),s.length());
return os;
}
int getline(istream &is, RJS_String &s, char delim, int dropit)
{
int ch;
// should check for errors on is first
s="";
while ( ((ch = is.get()) != EOF) && (ch != delim)) s+=char(ch);
if (ch==delim && !dropit) s+=delim;
return s.length();
}
istream &operator>>(istream &is, RJS_String &s)
{
// should check for errors on is first
int ch;
s="";
while ( ((ch = is.get()) != EOF) && (isspace(ch))) ; // spin
if (ch!=EOF) {
s+=char(ch);
while ( ((ch = is.get()) != EOF) && (!isspace(ch))) s+=char(ch);
}
return is;
}